package com.china08.yxyapi.entity.mg.homework;

import java.util.Date;

import javax.persistence.Id;
import javax.persistence.Transient;

import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import com.china08.yxyapi.entity.mg.MongoBaseEntityNoId;
import com.china08.yxyapi.repository.mg.homework.HomeworkTaskQuesRepository;
import com.china08.yxyapi.util.SpringContextUtil;

/**
 * 作业:任务:报告:每一个作业，每个学生一条记录
 * 
 * @author Richard Wang
 *
 */
@Document(collection = "yxy.tea.homework.task.report")
public class HomeworkTaskReport extends MongoBaseEntityNoId {

    private static final long serialVersionUID = 4877542982157476466L;

    /** 主键 */
    @Id
    private String id;

    /** 任务:ID */
    @Indexed
    @Field(value = "task_id")
    private String taskId;

    /** 标题 */
    @Field(value = "title")
    private String title;

    /**
     * 试题类标题
     */
    @Field(value = "sub_title")
    private String subTitle;

    /** 学生:ID */
    @Indexed
    @Field(value = "student_id")
    private String studentId;

    /** 学生:名称 */
    @Indexed
    @Field(value = "student_nick")
    private String studentNick;

    /** 学生头像 */
    @Field(value = "avatar")
    private String avatar;

    /** 学校:ID */
    @Field(value = "school_id")
    private String schoolId;

    /** 班级:ID */
    @Field(value = "class_id")
    private String classId;

    /** 班级名称 */
    @Field(value = "class_name")
    private String className;

    /** 年级:01年级~12年级 */
    @Field(value = "grade")
    private String grade;

    /** 年度: 每年9月前,算上一年度, 9月后算本年度. */
    @Field(value = "annual")
    private String annual;

    /** 学段 */
    @Field(value = "stage")
    private String stage;

    /** 学科 */
    @Field(value = "subject")
    private String subject;

    /** 学科名称 */
    @Field(value = "subject_name")
    private String subjectName;

    /** 作业完成情况:-1-逾期未提交,0-未做,1-完成 ,2-已批阅,3-答题中 */
    @Field(value = "status_of_finished")
    private Integer statusOfFinished = 0;

    /** 作业完成时间 **/
    @Field(value = "finished_date")
    private Date finishedDate = new Date();

    /**
     * 试题是否完成,作业类型为2 , 同时存在试题类和通知类（0：未完成，1：已完成）
     */
    @Field(value = "ques_of_finished")
    private Integer quesOfFinished = 0;

    /**
     * 通知类试题是否完成, 作业类型为2 , 同时存在试题类和通知类（0：未完成，1：已完成）
     */
    @Field(value = "noti_of_finished")
    private Integer notiOfFinished = 0;

    /**
     * 任务时长(秒)
     */
    @Field(value = "duration")
    private Long duration = 0L;

    /** 发布时间 */
    @Field(value = "publish_date")
    private Date publishDate;

    /**
     * 本任务截止完成时间，此时间之后就不能答题
     */
    @Field(value = "predict_date")
    private Date predictDate;

    /** 发布答案解析：0--提交作业后，1--截止时间后 */
    @Field(value = "publish_answer")
    private Integer publishAnswer;

    /**
     * 正确率，在老师批改完作业之后计算，小数点后两位
     */
    @Deprecated
    @Field(value = "right_rate")
    private Double rightRate = 0.00;

    /**
     * 得分率，在老师批改完作业之后计算，小数点后两位
     */
    @Field(value = "score_rate")
    private Double scoreRate = 0.00;

    /**
     * 在本次作业中，我的排名次（根据班级排名），<br/>
     * 需要定时批量统计,统计整个班的数据
     */
    @Deprecated
    @Field(value = "my_ranking")
    private Integer myRanking;

    /** 正确率，在老师批改完作业之后计算， */
    @Deprecated
    @Field(value = "single_select_right_rate")
    private Double singleSelectRighttRate;

    /** 正确率，在老师批改完作业之后计算， */
    @Deprecated
    @Field(value = "more_select_right_rate")
    private Double moreSelectRightRate;

    /** 正确率，在老师批改完作业之后计算， */
    @Deprecated
    @Field(value = "fill_right_rate")
    private Double fillRightRate;

    /** 正确率，在老师批改完作业之后计算， */
    @Deprecated
    @Field(value = "solve_right_rate")
    private Double solveRightRate;

    /**
     * 对学生的评价。
     */
    @Field(value = "evaluate")
    private String evaluate;

    /**
     * 试题类型 0：试题类作业，1：通知类作业 2：阅读类作业。</br>
     * 2017.08.23 将2更改为"阅读类作业", 如果本次发布的作业为多类型的, 使用拼接的方式</br>
     * 例如: 012代表"试题,通知,阅读"; 02代表"试题,阅读"
     */
    @Field(value = "task_type")
    private String taskType;

    /**
     * 作业发布的来源 00--作业系统 01--备授课系统
     */
    @Field(value = "source")
    private Integer source;

    /**
     * 备授课类型: 0--预习作业 1--课后作业</br>
     * 2017.08.25 王慧超 </br>
     * 作业加预习作业和课后作业字段 </br>
     * 预习作业：备授课发送的标记为预习作业的作业 </br>
     * 课后作业：作业系统布置的以及备授课发送的标记为课后作业的作业
     * 
     */
    @Field(value = "lecture_type")
    private Integer lectureType;

    /**
     * 备授课的id
     */
    @Field(value = "lecture_id")
    private String lectureId;

    /** 0 已截止 1进行中 */
    @Field(value = "task_status")
    private int taskStatus;

    /** 试题数量 */
    @Transient
    private int quesCount;

    /**
     * 当此数据发生变化时, 将此状态更改为 0, total表进行统计之后, 将此字段更新为1,已经同步 </br>
     * 0:未同步 1:已同步
     */
    @Field(value = "synch_tea_mistakes")
    private Integer synchTeaMistakes;

    /**
     * 
     */
    @Field(value = "synch_stu_mistakes")
    private Integer synchStuMistakes;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(String schoolId) {
        this.schoolId = schoolId;
    }

    public String getClassId() {
        return classId;
    }

    public void setClassId(String classId) {
        this.classId = classId;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getAnnual() {
        return annual;
    }

    public void setAnnual(String annual) {
        this.annual = annual;
    }

    public String getStage() {
        return stage;
    }

    public void setStage(String stage) {
        this.stage = stage;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public Integer getStatusOfFinished() {
        return statusOfFinished;
    }

    public void setStatusOfFinished(Integer statusOfFinished) {
        this.statusOfFinished = statusOfFinished;
    }

    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }

    public Date getPredictDate() {
        return predictDate;
    }

    public void setPredictDate(Date predictDate) {
        this.predictDate = predictDate;
    }

    public Double getRightRate() {
        return rightRate;
    }

    public void setRightRate(Double rightRate) {
        this.rightRate = rightRate;
    }

    public Integer getMyRanking() {
        return myRanking;
    }

    public void setMyRanking(Integer myRanking) {
        this.myRanking = myRanking;
    }

    public Double getSingleSelectRighttRate() {
        return singleSelectRighttRate;
    }

    public void setSingleSelectRighttRate(Double singleSelectRighttRate) {
        this.singleSelectRighttRate = singleSelectRighttRate;
    }

    public Double getMoreSelectRightRate() {
        return moreSelectRightRate;
    }

    public void setMoreSelectRightRate(Double moreSelectRightRate) {
        this.moreSelectRightRate = moreSelectRightRate;
    }

    public Double getFillRightRate() {
        return fillRightRate;
    }

    public void setFillRightRate(Double fillRightRate) {
        this.fillRightRate = fillRightRate;
    }

    public Double getSolveRightRate() {
        return solveRightRate;
    }

    public void setSolveRightRate(Double solveRightRate) {
        this.solveRightRate = solveRightRate;
    }

    public String getEvaluate() {
        return evaluate;
    }

    public void setEvaluate(String evaluate) {
        this.evaluate = evaluate;
    }

    public int getQuesCount() {
        HomeworkTaskQuesRepository homeworkTaskQuesRepository = SpringContextUtil
                .getBean(HomeworkTaskQuesRepository.class);
        String quesType = "2";
        Integer quesCount = homeworkTaskQuesRepository.countByTaskIdAndQuesTypeNot(taskId, quesType);
        return quesCount;
    }

    public void setQuesCount(int quesCount) {
        this.quesCount = quesCount;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getStudentNick() {
        return studentNick;
    }

    public void setStudentNick(String studentNick) {
        this.studentNick = studentNick;
    }

    public Integer getPublishAnswer() {
        return publishAnswer;
    }

    public void setPublishAnswer(Integer publishAnswer) {
        this.publishAnswer = publishAnswer;
    }

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public Date getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Date publishDate) {
        this.publishDate = publishDate;
    }

    public String getTaskType() {
        return taskType;
    }

    public void setTaskType(String taskType) {
        this.taskType = taskType;
    }

    public Integer getQuesOfFinished() {
        return quesOfFinished;
    }

    public void setQuesOfFinished(Integer quesOfFinished) {
        this.quesOfFinished = quesOfFinished;
    }

    public Integer getNotiOfFinished() {
        return notiOfFinished;
    }

    public void setNotiOfFinished(Integer notiOfFinished) {
        this.notiOfFinished = notiOfFinished;
    }

    public Date getFinishedDate() {
        return finishedDate;
    }

    public void setFinishedDate(Date finishedDate) {
        this.finishedDate = finishedDate;
    }

    public Integer getSource() {
        return source;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public String getLectureId() {
        return lectureId;
    }

    public void setLectureId(String lectureId) {
        this.lectureId = lectureId;
    }

    public Integer getLectureType() {
        return lectureType;
    }

    public void setLectureType(Integer lectureType) {
        this.lectureType = lectureType;
    }

    public Integer getSynchTeaMistakes() {
        return synchTeaMistakes;
    }

    public void setSynchTeaMistakes(Integer synchTeaMistakes) {
        this.synchTeaMistakes = synchTeaMistakes;
    }

    public Integer getSynchStuMistakes() {
        return synchStuMistakes;
    }

    public void setSynchStuMistakes(Integer synchStuMistakes) {
        this.synchStuMistakes = synchStuMistakes;
    }

    public int getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(int taskStatus) {
        this.taskStatus = taskStatus;
    }

    public Double getScoreRate() {
        return scoreRate;
    }

    public void setScoreRate(Double scoreRate) {
        this.scoreRate = scoreRate;
    }
}
